1 <!-- This is the main page which obtains the information if student login or teacher login is required -->
2
3 <html>
4 <head>
5     <title>Internal Mark Main Page</title>
6     <link rel=
"stylesheet" type="text/css" href="indexcss.css" />
7     </head>
8     <?php
9     session_start();
10     $name=
"localhost";
11     $user=
"root";
12     $pass=
"";
13     $db=
"studentinfo";
14     $conn=mysqli_connect($name,$user,$pass,$db);
15     
if($conn->connect_error)
16        die(
"Connection failure").$conn->connect_error;
17     
else{
18     
if(isset($_POST['tid']) and isset($_POST['tpassword'])){
19         $id = $_POST[
'tid'];
20         $pass = $_POST[
'tpassword'];
21         $query =
"SELECT * FROM `teacher` WHERE tid='$id' and pass='$pass'";
22          $result = $conn->query($query);
23         $count = $result->num_rows;
24         
if ($count == 1){
25             $_SESSION[
'tid'] = $id;
26             $_SESSION[
'tpassword']=$pass;
27             $_SESSION[
'tsub']=$_POST['tsub'];
28             header(
'Location: tlogin.php');
29         }
30         
else
31         {
32             $msg =
"Wrong credentials";
33         }
34     }
35
36     
if(isset($msg) & !empty($msg)){
37         echo $msg;
38     }
39         
if(isset($_POST['sid'])){
40         $id = $_POST[
'sid'];
41        
42         $query =
"SELECT * FROM `student` WHERE sid='$id'";
43          $result = $conn->query($query);
44         $count = $result->num_rows;
45         
if ($count == 1){
46             $_SESSION[
'sid'] = $id;
47             
48             header(
'Location: slogin.php');
49         }
50         
else
51         {
52             $msg =
"Wrong credentials";
53         }
54     }
55
56     
if(isset($msg) & !empty($msg)){
57         echo $msg;
58     }
59     }
60
61     ?>
62     <body>
63         <center><h1> STUDENT
'S PORTAL</h1></center>
64     <div id=
"d1">
65          <h3>STUDENT LOGIN</h3>
66         <form method=
"post">
67         <input type=
"text" name="sid" placeholder="Enter the Student id" required/><br><br>
68             <center> <input type=
"submit" name="Login" /></center>
69         </form>
70         </div>
71         <div id=
"d2">
72              <h3>TEACHER LOGIN</h3>
73         <form method=
"post" name="tlogin">
74             <input type=
"text" name="tid" placeholder="Enter the Teacher Id" required/><br><br><br>
75             <input type=
"password" name="tpassword" placeholder="Enter the password" required/><br><br>
76             <input type=
"text" name="tsub" placeholder="Enter the subject code" required /><br><br>
77             <center> <input type=
"submit" name="Login" /></center>
78             </form>
79         </div>
80     </body>
81 </html>


Gõ tìm kiếm nhanh...